package org.dydl.controller.system;

import java.util.Calendar;
import java.util.Date;

import org.dydl.common.dto.ResponseMessage;
import org.dydl.service.system.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/sysLog")
public class SysLogController {

	@Autowired
	private ISysLogService sysLogService;

	/**
	 * 系统操作日志——查询、展示
	 * 
	 * @param page
	 *            当前页数
	 * @param rows
	 *            每页显示数
	 * @param keyword
	 *            查询用户名
	 * @param start_date
	 *            查询开始时间
	 * @param end_date
	 *            查询截止时间
	 * @return
	 */
	@RequestMapping("/list")
	public ResponseMessage list(int page, int rows, String operatorId,
			@DateTimeFormat(pattern = "yyyy-MM-dd") Date start_date,
			@DateTimeFormat(pattern = "yyyy-MM-dd") Date end_date) {
		// 结束日期天数加1
		Calendar cal = null;
		if (end_date != null) {
			cal = Calendar.getInstance();
			cal.setTime(end_date);
			cal.add(Calendar.DAY_OF_YEAR, 1);
		}

		// Search search = new Search();
		// search.setPage(page -
		// 1).setMaxResults(rows).addSortDesc("id").addFilterEqual("operatorId",
		// operatorId)
		// .addFilterGreaterOrEqual("logTime", start_date)
		// .addFilterLessOrEqual("logTime", cal != null ? cal.getTime() : null);

		// ResponseMessage msg = sysLogService.searchList(page, rows, operatorId,
		// start_date, end_date);// .search(search);
		ResponseMessage msg = sysLogService.getAll();
		return msg;
	}

}
